package com.chensj.ws.client;

import com.chensj.ws.service.IMyService;

import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import java.net.MalformedURLException;
import java.net.URL;

/**
 * @author chensj
 * @title 客户端调用WebService接口
 * @email chensj@winning.com.cn
 * @package com.chensj.ws
 * @date: 2018-12-16 下午9:43
 * wsimport -d /home/chensj/IdeaProjects/wslessondemo/client-demo/src/main/java/ -keep -verbose http://localhost:8888/ws?wsdl
 * wsimport -d G:\code\java\ws\client-demo\src\main\java  -keep -verbose http://localhost:8888/ws?wsdl
 * -d 指定生成文件路径
 * -keep 指定生成源码
 * -verbose 生成的详细信息
 */
public class TestClient {
    public static void main(String[] args){
        try {
            URL url = new URL("http://localhost:8888/ws?wsdl");
            QName qName = new QName("http://service.ws.chensj.com/","MyServiceImplService");
            Service service = Service.create(url,qName);
            IMyService myService = service.getPort(IMyService.class);
            System.out.println(myService.addMethod(5,6));
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
    }

}
